<template>
  <div class="board-column">
    <div v-if="headerText" class="board-column-header">
      {{ headerText }}
    </div>
    <draggable
      :list="list"
      v-bind="$attrs"
      :set-data="setData"
      class="board-column-content"
      @change="onChange">
      <div v-for="element in list" v-if="element['display']===1" :key="element['id']"
           :style="mode===1?'width:124px;':mode===2?'width:93px;':'flex:1'" class="board-item">
        <el-image :src="element['icon']" class="board-item-icon">
          <div slot="error" class="board-item-icon">
            <i class="el-icon-picture-outline"/>
          </div>
        </el-image>
        <!--<img :src="element['icon']" onerror="javascript:this.src='/static/img/model.png';" class="board-item-icon">-->
        <label class="board-item-label">{{ element['new_name'] || element['label'] }}</label>
      </div>
    </draggable>
  </div>
</template>
<script>
import draggable from 'vuedraggable';
export default {
  name: 'DragKanbanDemo',
  components: {
    draggable
  },
  props: {
    headerText: {
      type: String,
      default: ''
    },
    mode: {
      type: Number,
      default: 1
    },
    options: {
      type: Object,
      default() {
        return {}
      }
    },
    list: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    setData(dataTransfer) {
      // to avoid Firefox bug
      // Detail see : https://github.com/RubaXa/Sortable/issues/1012
      dataTransfer.setData('Text', '');
    },
    onChange() {
      this.$emit('change');
    }
  }
}
</script>
<style lang="scss" scoped>
.board-column {
  width: 375px;
  /*min-height: 667px;*/
  height: auto;
  overflow: hidden;
  background: #f0f0f0;
  border-radius: 3px;

  .board-column-header {
    height: 50px;
    line-height: 50px;
    overflow: hidden;
    padding: 0 20px;
    text-align: center;
    background: #333;
    color: #fff;
    border-radius: 3px 3px 0 0;
  }

  /*==============3宫格==============*/
  .board-column-content {
    height: auto;
    min-height: 60px;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;

    .board-item {
      cursor: pointer;
      height: 124px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background-color: #fff;
      text-align: center;
      box-sizing: border-box;
      border: 1px solid #f1f2f3;
    }

    .board-item-icon {
      width: 55px;
      height: 55px;
      margin-bottom: 10px;
    }

    .board-item-label {
      color: #101010;
      font-size: 13px;
    }
  }
  /*===============================*/
}
</style>

